<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| 	example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
|	http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are two reserved routes:
|
|	$route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
|	$route['scaffolding_trigger'] = 'scaffolding';
|
| This route lets you set a "secret" word that will trigger the
| scaffolding feature for added security. Note: Scaffolding must be
| enabled in the controller in which you intend to use it.   The reserved
| routes must come before any wildcard or regular expression routes.
|
*/

/*********************************************************************
 * CRUD routing. We define a list of first-class entities
 * for which we expose public URIs as part of the AIR2 API,
 * and set up the standard conventions for the URI patterns.
 * NOTE that these all should inherit (or implement) the internal
 * API of AIR2_CRUD_Controller.
 */

/*
 * CUSTOM routing must occur before CRUD controller routing, to avoid the CRUD
 * wildcards stealing URI's
 */


/*
 * CRUD controller routing
 * -NOTE the _controller extension is omitted.
 */
$crud_controllers = array(
    'test_crud',
    'test_related_crud',
    'organization',
    'user',
    'project',
    'source',
    'batch',
    'tag',
    'inquiry',
    'savedsearch',
    'submission',
    'response',
    'import',
);

foreach ($crud_controllers as $name) {
    $route[$name] = array(
        'GET'   => $name . '/crud_GET_list',
        'POST'  => $name . '/crud_POST',
    );
    $route[$name.'/([\w]+)'] = array(
        'GET'       => $name.'/crud_GET_one/$1',
        'PUT'       => $name.'/crud_PUT/$1',
        'DELETE'    => $name.'/crud_DELETE/$1',
    );

    // add a route for tagging, which will be optionally used if
    // the controller has set $taggable = true
    $route[$name.'/([\w]+)/tags'] = array(
        'GET'   => $name . '/crud_tags_list/$1',
        'POST'  => $name . '/crud_tags_add/$1',
    );
    $route[$name.'/([\w]+)/tags/([\w]+)'] = array(
        'DELETE'    => $name.'/crud_tags_remove/$1/$2',
    );

    // redirect route for any related component
    // method($uuid, $relation_name, $rel_uuid)
    $route[$name.'/([\w]+)/([\w]+)'] = array(
        'GET'   => $name . '/crud_GET_list_related/$1/$2',
        'POST'  => $name . '/crud_POST_related/$1/$2',
    );
    $route[$name.'/([\w]+)/([\w]+)/([\w]+)'] = array(
        'GET'       => $name.'/crud_GET_one_related/$1/$2/$3',
        'PUT'       => $name.'/crud_PUT_related/$1/$2/$3',
        'DELETE'    => $name.'/crud_DELETE_related/$1/$2/$3',
    );
}

// PUT to batch/123/contents for mass add/removes of batch items
$route['batch/([\w]+)/([\w]+)']['PUT'] = 'batch/PUT_batch_contents/$1/$2';

// upload controller - file uploads must treat "POST" like "PUT"
$route['upload']['GET'] = 'upload/list_tanks';
$route['upload/activity']['GET'] = 'upload/list_valid_actm';
$route['upload/([\w]+)']['GET'] = 'upload/list_tanks/$1';
$route['upload']['POST'] = 'upload/do_upload';
$route['upload/([\w]+)']['POST'] = 'upload/do_upload/$1';
$route['upload/([\w]+)']['PUT'] = 'upload/do_upload/$1';
$route['upload/([\w]+)/preview']['GET'] = 'upload/get_preview/$1';
$route['upload/([\w]+)/submit']['POST'] = 'upload/do_submit/$1';

// import controller - resolve conflict functionality
$route['import/([\w]+)/sources/([\w]+)/resolve'] = array(
    'POST' => 'import/resolve_conflicts/$1/$2',
);

$route['search/active-sources'] = 'search/activesources';

// password reset controller
$route['password/([\w]+)'] = 'password/change_password_page/$1';

$route['default_controller'] = "home_controller";
$route['scaffolding_trigger'] = "";


/* End of file routes.php */
/* Location: ./app/config/routes.php */
